package com.xtwy.sevice.impl;


import com.xtwy.dao.UserInfoDao;
import com.xtwy.entity.SysRole;
import com.xtwy.entity.UserInfo;
import com.xtwy.sevice.UserInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 *
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Resource
    private UserInfoDao userInfoDao;

    @Override
    public UserInfo findByUsername(String username) {
        System.out.println("根据用户名查找用户");
        return userInfoDao.findByUsername(username);
    }

    @Override
    public Set<String> getUserInfoAndSysRole(String username) {
        UserInfo ui = userInfoDao.findUserInfoAndSysRole(username);
        List<SysRole> list = ui.getRoleList();
        Set<String> set=new HashSet()  ;
        for (SysRole role:list ) {
            //将角色名添加到set进行去重
             set.add(role.getRole())  ;
        }
        return set;
    }
}